package com.example.finalproject.car;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

@Controller
public class CarController {
    @Autowired
    private CarService carService;

    //首页点击汽车图片发送请求，从数据库返回对应汽车的数据展示
    @RequestMapping("/getCar_1")
    public String getCar_1(Model model){
        String carId = "01";
        Car car = carService.selectCarById(carId);
        model.addAttribute("car",car);
        return "details";
    }

    @RequestMapping("/getCar_2")
    public String getCar_2(Model model){
        String carId = "02";
        Car car = carService.selectCarById(carId);
        model.addAttribute("car",car);
        return "details";
    }

    @RequestMapping("/getCar_3")
    public String getCar_3(Model model){
        String carId = "03";
        Car car = carService.selectCarById(carId);
        model.addAttribute("car",car);
        return "details";
    }

    @RequestMapping("/getCar_4")
    public String getCar_4(Model model){
        String carId = "04";
        Car car = carService.selectCarById(carId);
        model.addAttribute("car",car);
        return "details";
    }
    @RequestMapping("/getCar_5")
    public String getCar_5(Model model){
        String carId = "05";
        Car car = carService.selectCarById(carId);
        model.addAttribute("car",car);
        return "details";
    }
    @RequestMapping("/getCar_6")
    public String getCar_6(Model model){
        String carId = "06";
        Car car = carService.selectCarById(carId);
        model.addAttribute("car",car);
        return "details";
    }
    @RequestMapping("/getCar_7")
    public String getCar_7(Model model){
        String carId = "07";
        Car car = carService.selectCarById(carId);
        model.addAttribute("car",car);
        return "details";
    }
    @RequestMapping("/getCar_8")
    public String getCar_8(Model model){
        String carId = "08";
        Car car = carService.selectCarById(carId);
        model.addAttribute("car",car);
        return "details";
    }
}
